package com.fzy.silntgym.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;

import com.fzy.silntgym.R;

public class WelcomeActivity extends AppCompatActivity {
    private SharedPreferences preferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_welcome);
        preferences = getSharedPreferences("scount", MODE_PRIVATE);//判断是否为首次登陆
        final int scount = preferences.getInt("scount",0);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if(scount == 0){
                    SharedPreferences.Editor editor = preferences.edit();
                    //存入数据
                    editor.putInt("scount",1);
                    //提交修改
                    editor.apply();
                    Intent intentToWelcome = new Intent(WelcomeActivity.this,WhatsNewActivity.class);
                    startActivity(intentToWelcome);
                }
                else {
                    Intent intentToMain = new Intent(WelcomeActivity.this,StartActivity.class);
                    startActivity(intentToMain);
                }
                finish();
            }
        },1500);
    }
}
